$(document).ready(function(){
	//var URL = "http://twitter.com/statuses/user_timeline/imaocande.json?count=40&callback=?";
	var URL = "http://twitter.com/statuses/user_timeline/imaocandeforest.json?count=40&callback=?";
	function getTweet(callback) {
		$.getJSON(URL, function(results) {
			// データ
			var data = [];
			// オプション
			var options = {};
			options.xaxis = {};
			var ticks = [];
			options.xaxis.ticks = ticks;
			
			var idx = 0;
			$.each(results, function(i, message) {
				message.created_at = new Date(message.created_at);
				try {
					var d = jQuery.parseJSON(message.text);
					//var d = parseXML(unescapeHTML(message.text));
					data.push([idx, d.count]);
					ticks.push([idx, dateToShortStr(message.created_at)]);
					idx++;
				} catch ( e ) {
					// エラーは無視。。				
				}
			});
			
			$.plot($("#placeholder"),
				[{
					data: data, 
					lines: { show: true, fill: true }
				}], options);
			
			if ( callback ) {
				callback();
			}
		});
	}

	//$("#refresh").bind("tap", function() {
	$("#refresh").click( function() {
		//alert("hello");
		$.mobile.pageLoading();
		getTweet(function() {
			$.mobile.pageLoading(true);
		});
	});

	getTweet();

});

